<?php
/**
 * User: @lixu
 * Date: 2019-05-10
 * Time: 11:13
 */

ini_set('display_errors', 1);
error_reporting(-1);
require_once '/data/wwwroot/g_vendor/autoload.php';

use Doraemon\model\Store\ShenJianGoods as mShenJianGoods;
use Doraemon\model\Store\ShenJianGoodsSourceData as mShenJianGoodsSourceData;


$goods = mShenJianGoods::select('*', ['status' => mShenJianGoods::STATUS_NORMAL]);

foreach ($goods as $value) {

    $id = mShenJianGoodsSourceData::get('id', ['item_id' => $value['item_id'], 'type' => $value['type']]);
    if (!$id) {
        $data = [
            'shenjian_goods_id' => $value['id'],
            'item_id' => $value['item_id'],
            'type' => $value['type'],
            'source_data' => $value['source_data'],
            'images' => $value['images'],
            'params' => $value['params'],
            'sku' => $value['sku'],
        ];
        echo mShenJianGoodsSourceData::addRecord($data);
    }

}

var_dump(count($goods));
die;